"use strict";

var __extends = this && this.__extends || function() {
    var extendStatics = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(d, b) {
        d.__proto__ = b;
    } || function(d, b) {
        for (var p in b) b.hasOwnProperty(p) && (d[p] = b[p]);
    };
    return function(d, b) {
        function __() {
            this.constructor = d;
        }
        extendStatics(d, b), d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, 
        new __());
    };
}(), powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var AnimatedText = function() {
            function AnimatedText(name) {
                this.mainText = jsCommon.CssConstants.createClassAndSelector("mainText"), this.name = name, 
                this.visualConfiguration = {
                    maxFontSize: 60
                };
            }
            return AnimatedText.prototype.getMetaDataColumn = function(dataView) {
                if (dataView && dataView.metadata && dataView.metadata.columns) for (var i = 0, ilen = dataView.metadata.columns.length; i < ilen; i++) {
                    var column = dataView.metadata.columns[i];
                    if (column.isMeasure) {
                        this.metaDataColumn = column;
                        break;
                    }
                }
            }, AnimatedText.prototype.getAdjustedFontHeight = function(availableWidth, textToMeasure, seedFontHeight) {
                var textProperties = {
                    fontFamily: null,
                    fontSize: null,
                    text: textToMeasure
                }, fontHeight = this.getAdjustedFontHeightCore(textProperties, availableWidth, seedFontHeight, 0);
                return fontHeight;
            }, AnimatedText.prototype.getAdjustedFontHeightCore = function(textProperties, availableWidth, seedFontHeight, iteration) {
                if (iteration > 10) return seedFontHeight;
                textProperties.fontSize = jsCommon.PixelConverter.toString(seedFontHeight);
                var candidateLength = powerbi.TextMeasurementService.measureSvgTextWidth(textProperties);
                return candidateLength < availableWidth ? seedFontHeight : this.getAdjustedFontHeightCore(textProperties, availableWidth, .9 * seedFontHeight, iteration + 1);
            }, AnimatedText.prototype.clear = function() {
                this.svg.select(this.mainText.selector).text("");
            }, AnimatedText.prototype.doValueTransition = function(startValue, endValue, displayUnitSystemType, animationOptions, duration, forceUpdate, formatter) {
                if (forceUpdate || startValue !== endValue || null == endValue) {
                    startValue || (startValue = 0);
                    var svg = this.svg, viewport = this.currentViewport, height = viewport.height, width = viewport.width, endValueArr = [ endValue ], seedFontHeight = this.getSeedFontHeight(width, height), translateX = this.getTranslateX(width), translateY = this.getTranslateY(seedFontHeight), metaDataColumn = this.metaDataColumn;
                    formatter || (formatter = visuals.valueFormatter.create({
                        format: this.getFormatString(this.dataPointObjects, metaDataColumn),
                        value: endValue,
                        displayUnitSystemType: displayUnitSystemType,
                        formatSingleValues: !0,
                        allowFormatBeautification: !0,
                        columnType: metaDataColumn ? metaDataColumn.type : void 0
                    }));
                    var startText = formatter.format(startValue), endText = formatter.format(endValue);
                    svg.attr("class", this.name);
                    var textElement = svg.selectAll("text").data(endValueArr);
                    textElement.enter().append("text").attr("class", this.mainText.class);
                    var fontHeight = this.getAdjustedFontHeight(width, endText, seedFontHeight);
                    translateY = this.getTranslateY(fontHeight + (height - fontHeight) / 2);
                    var textElementUpdate = textElement.text(startText).attr({
                        "text-anchor": this.getTextAnchor(),
                        "font-size": fontHeight,
                        transform: visuals.SVGUtil.translate(translateX, translateY)
                    }).style({
                        fill: this.style.titleText.color.value
                    }).call(visuals.tooltipUtils.tooltipUpdate, [ startText ]);
                    if (null == endValue) textElementUpdate.text(endText).call(visuals.tooltipUtils.tooltipUpdate, [ endText ]); else if (metaDataColumn && visuals.AxisHelper.isDateTime(metaDataColumn.type)) textElementUpdate.text(endText).call(visuals.tooltipUtils.tooltipUpdate, [ endText ]); else {
                        var interpolatedValue_1 = startValue;
                        textElementUpdate.transition().duration(duration).tween("text", function(d) {
                            var i = d3.interpolate(interpolatedValue_1, d);
                            return function(t) {
                                var num = i(t);
                                this.textContent = formatter.format(num);
                            };
                        });
                    }
                    visuals.SVGUtil.flushAllD3TransitionsIfNeeded(animationOptions);
                }
            }, AnimatedText.prototype.setTextColor = function(color) {
                this.style.titleText.color.value = color;
            }, AnimatedText.prototype.getSeedFontHeight = function(boundingWidth, boundingHeight) {
                var estimatedSize = Math.floor(.75 * Math.min(boundingWidth, boundingHeight)), maxFontSize = this.visualConfiguration.maxFontSize;
                return maxFontSize ? Math.min(maxFontSize, estimatedSize) : estimatedSize;
            }, AnimatedText.prototype.getTranslateX = function(width) {
                if (this.visualConfiguration) switch (this.visualConfiguration.align) {
                  case "left":
                    return 0;

                  case "right":
                    return width;
                }
                return width / 2;
            }, AnimatedText.prototype.getTranslateY = function(height) {
                return height;
            }, AnimatedText.prototype.getTextAnchor = function() {
                if (this.visualConfiguration) switch (this.visualConfiguration.align) {
                  case "left":
                    return "start";

                  case "right":
                    return "end";
                }
                return "middle";
            }, AnimatedText.prototype.getFormatString = function(dataPointObjects, column) {
                return visuals.valueFormatter.getFormatStringWithDataPointObjects(dataPointObjects, column, visuals.StandardObjectPropertyIdentifiers.formatString);
            }, AnimatedText;
        }();
        visuals.AnimatedText = AnimatedText;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var AnimatedNumber = function(_super) {
            function AnimatedNumber(svg, animator) {
                var _this = _super.call(this, "animatedNumber") || this;
                return svg && (_this.svg = svg), animator && (_this.animator = animator), _this;
            }
            return __extends(AnimatedNumber, _super), AnimatedNumber.prototype.init = function(options) {
                this.options = options;
                var element = options.element;
                this.svg || (this.svg = d3.select(element.get(0)).append("svg")), this.currentViewport = options.viewport, 
                this.hostServices = options.host, this.style = options.style, this.updateViewportDependantProperties();
            }, AnimatedNumber.prototype.updateViewportDependantProperties = function() {
                var viewport = this.currentViewport;
                this.svg.attr("width", viewport.width).attr("height", viewport.height);
            }, AnimatedNumber.prototype.update = function(options) {
                this.currentViewport = options.viewport;
                var dataViews = this.dataViews = options.dataViews;
                if (dataViews && dataViews[0]) {
                    var dataView = dataViews[0];
                    this.updateViewportDependantProperties(), this.getMetaDataColumn(dataView);
                    var newValue = dataView && dataView.single ? dataView.single.value : 0;
                    this.updateInternal(newValue, options.suppressAnimations, !0, this.formatter);
                }
            }, AnimatedNumber.prototype.setFormatter = function(formatter) {
                this.formatter = formatter;
            }, AnimatedNumber.prototype.onDataChanged = function(options) {
                this.update({
                    dataViews: options.dataViews,
                    suppressAnimations: options.suppressAnimations,
                    viewport: this.currentViewport
                });
            }, AnimatedNumber.prototype.onResizing = function(viewport) {
                this.update({
                    dataViews: this.dataViews,
                    suppressAnimations: !0,
                    viewport: viewport
                });
            }, AnimatedNumber.prototype.canResizeTo = function(viewport) {
                return !0;
            }, AnimatedNumber.prototype.updateInternal = function(target, suppressAnimations, forceUpdate, formatter) {
                void 0 === forceUpdate && (forceUpdate = !1);
                var start = this.value, duration = visuals.AnimatorCommon.GetAnimationDuration(this.animator, suppressAnimations);
                this.doValueTransition(start, target, null, this.options.animation, duration, forceUpdate, formatter), 
                this.value = target;
            }, AnimatedNumber;
        }(visuals.AnimatedText);
        visuals.AnimatedNumber = AnimatedNumber;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {})), define("SingleValueVisuals/animatedNumberModule", [ "require", "exports" ], function(require, exports) {
    function createAnimatedNumber() {
        return new powerbi.visuals.AnimatedNumber();
    }
    Object.defineProperty(exports, "__esModule", {
        value: !0
    }), exports.createAnimatedNumber = createAnimatedNumber;
});

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var CardDefaultStyle = visuals.CardUtil.DefaultStyle, createClassAndSelector = jsCommon.CssConstants.createClassAndSelector, getKpiImageMetadata = powerbi.visuals.KpiUtil.getKpiImageMetadata, TextUtil = powerbi.visuals.TextUtil, Card = function(_super) {
            function Card(options) {
                var _this = _super.call(this, Card.cardClassName) || this;
                return _this.isScrollable = !1, _this.displayUnitSystemType = powerbi.DisplayUnitSystemType.WholeUnits, 
                options && (_this.isScrollable = !!options.isScrollable, _this.customFontFamilyForDataLabel = options.customFontFamilyForDataLabel, 
                options.animator && (_this.animator = options.animator), null != options.displayUnitSystemType && (_this.displayUnitSystemType = options.displayUnitSystemType), 
                options.cardSmallViewportProperties && (_this.cardSmallViewportProperties = options.cardSmallViewportProperties)), 
                _this;
            }
            return __extends(Card, _super), Card.prototype.init = function(options) {
                this.animationOptions = options.animation;
                var element = options.element;
                this.kpiImage = d3.select(element.get(0)).append("div").classed(Card.KPIImage.class, !0);
                var svg = this.svg = d3.select(element.get(0)).append("svg");
                this.graphicsContext = svg.append("g"), this.currentViewport = options.viewport, 
                this.hostServices = options.host, this.style = options.style, this.updateViewportProperties(), 
                this.isScrollable && (svg.attr("class", Card.cardClassName), this.labelContext = svg.append("g"));
            }, Card.prototype.onDataChanged = function(options) {
                var value, dataPointObjects, dataView = options.dataViews[0];
                if (dataView) {
                    this.getMetaDataColumn(dataView), dataView.single && (value = dataView.single.value, 
                    dataPointObjects = dataView.single.objects), this.cardFormatSetting = this.getDefaultFormatSettings();
                    var dataViewMetadata = dataView.metadata;
                    if (dataViewMetadata) {
                        var objects = dataViewMetadata.objects;
                        if (objects) {
                            var labelSettings = this.cardFormatSetting.labelSettings, labelsObj = objects.labels;
                            labelsObj && labelSettings && visuals.LabelUtils.updateLabelSettingsFromLabelsObject(labelsObj, labelSettings), 
                            labelSettings.precision !== visuals.dataLabelUtils.defaultLabelPrecision && labelSettings.precision < 0 && (labelSettings.precision = 0);
                            var categoryLabelsObj = objects.categoryLabels, categoryLabelSettings = this.cardFormatSetting.categoryLabelSetting;
                            categoryLabelsObj && categoryLabelSettings && visuals.LabelUtils.updateLabelSettingsFromLabelsObject(categoryLabelsObj, categoryLabelSettings), 
                            this.cardFormatSetting.wordWrap = powerbi.DataViewObjects.getValue(objects, visuals.cardProps.wordWrap.show, this.cardFormatSetting.wordWrap);
                        }
                    }
                }
                this.updateInternal(value, dataPointObjects, !0, !0);
            }, Card.prototype.onResizing = function(viewport) {
                this.currentViewport = viewport, this.updateViewportProperties(), this.updateInternal(this.value, this.dataPointObjects, !0, !0);
            }, Card.prototype.updateViewportProperties = function() {
                var viewport = this.currentViewport;
                this.svg.attr("width", viewport.width).attr("height", viewport.height);
            }, Card.prototype.setTextProperties = function(text, fontProperties) {
                Card.cardTextProperties = visuals.FontProperties.toTextProperties(fontProperties, text);
            }, Card.prototype.isSmallViewport = function() {
                return !!(this.cardSmallViewportProperties && this.currentViewport.width <= this.cardSmallViewportProperties.cardSmallViewportWidth);
            }, Card.prototype.getCardPrecision = function(isSmallViewport) {
                return void 0 === isSmallViewport && (isSmallViewport = !1), isSmallViewport ? visuals.dataLabelUtils.defaultLabelPrecision : this.cardFormatSetting.labelSettings.precision;
            }, Card.prototype.getCardDisplayUnits = function(isSmallViewport) {
                return void 0 === isSmallViewport && (isSmallViewport = !1), isSmallViewport ? 0 : this.cardFormatSetting.labelSettings.displayUnits;
            }, Card.prototype.getAdjustedFontHeight = function(availableWidth, textToMeasure, seedFontHeight) {
                var adjustedFontHeight = _super.prototype.getAdjustedFontHeight.call(this, availableWidth, textToMeasure, seedFontHeight);
                return Math.min(adjustedFontHeight, CardDefaultStyle.card.maxFontSize);
            }, Card.prototype.clear = function(valueOnly) {
                void 0 === valueOnly && (valueOnly = !1), this.svg.select(Card.Value.selector).text(""), 
                valueOnly || this.svg.select(Card.Label.selector).text(""), _super.prototype.clear.call(this);
            }, Card.prototype.updateInternal = function(target, dataPointObjects, suppressAnimations, forceUpdate) {
                void 0 === forceUpdate && (forceUpdate = !1);
                var start = this.value, duration = visuals.AnimatorCommon.GetAnimationDuration(this.animator, suppressAnimations);
                if (void 0 === target) return void (void 0 !== start && this.clear());
                var metaDataColumn = this.metaDataColumn, labelSettings = this.cardFormatSetting.labelSettings, categoryLabelSetting = this.cardFormatSetting.categoryLabelSetting, isSmallViewport = this.isSmallViewport(), precision = this.getCardPrecision(isSmallViewport), displayUnits = this.getCardDisplayUnits(isSmallViewport), isDefaultDisplayUnit = 0 === displayUnits, format = this.getFormatString(dataPointObjects, metaDataColumn), formatter = visuals.valueFormatter.create({
                    format: format,
                    value: isDefaultDisplayUnit ? target : displayUnits,
                    precision: visuals.dataLabelUtils.getLabelPrecision(precision, format),
                    displayUnitSystemType: isDefaultDisplayUnit && precision === visuals.dataLabelUtils.defaultLabelPrecision ? this.displayUnitSystemType : powerbi.DisplayUnitSystemType.WholeUnits,
                    formatSingleValues: !!isDefaultDisplayUnit,
                    allowFormatBeautification: !0,
                    columnType: metaDataColumn ? metaDataColumn.type : void 0
                }), formatSettings = this.cardFormatSetting, valueTextHeightInPx = labelSettings.fontProperties.size.px;
                this.setTextProperties(target, this.cardFormatSetting.categoryLabelSetting.fontProperties);
                var categoryLabelTextHeightInPx = categoryLabelSetting.show ? powerbi.TextMeasurementService.estimateSvgTextHeight(Card.cardTextProperties) : 0, categoryLabelHeightWithPadding = categoryLabelTextHeightInPx + CardDefaultStyle.label.paddingTop, width = this.currentViewport.width, height = this.currentViewport.height, translateX = this.getTranslateX(width), translateY = (height - categoryLabelHeightWithPadding - valueTextHeightInPx) / 2, statusGraphicInfo = getKpiImageMetadata(metaDataColumn, target, 1);
                if (this.isScrollable) {
                    if (!forceUpdate && start === target) return;
                    if (start === target || !_.isEmpty(target) && "string" == typeof target || (target = formatter.format(target)), 
                    statusGraphicInfo) this.graphicsContext.selectAll("text").remove(), this.displayStatusGraphic(statusGraphicInfo, translateX, translateY, valueTextHeightInPx); else {
                        this.kpiImage.selectAll("div").remove();
                        var translatedValueY = this.getTranslateY(valueTextHeightInPx + translateY), valueElement = this.graphicsContext.attr("transform", visuals.SVGUtil.translate(translateX, translatedValueY)).selectAll("text").data([ target ]);
                        if (valueElement.enter().append("text").attr("class", Card.Value.class), valueElement.text(function(d) {
                            return d;
                        }).style({
                            "text-anchor": this.getTextAnchor()
                        }).style(visuals.FontProperties.toSVGStyle(labelSettings.fontProperties)), formatSettings.wordWrap) {
                            var valueElementNode = valueElement.node();
                            TextUtil.wordBreak(valueElementNode, width, height - categoryLabelHeightWithPadding, void 0, !0);
                            var numLines = valueElementNode.childElementCount;
                            if (numLines > 1) {
                                var valueTextLineHeight = valueTextHeightInPx;
                                valueTextHeightInPx *= numLines, translateY = (height - categoryLabelHeightWithPadding - valueTextHeightInPx) / 2, 
                                translatedValueY = this.getTranslateY(valueTextLineHeight + translateY), this.graphicsContext.attr("transform", visuals.SVGUtil.translate(translateX, translatedValueY));
                            }
                        } else valueElement.call(visuals.AxisHelper.LabelLayoutStrategy.clip, width, powerbi.TextMeasurementService.svgEllipsis);
                        valueElement.append("title").text(function(d) {
                            return d;
                        }), valueElement.exit().remove();
                    }
                    if (categoryLabelSetting.show && metaDataColumn && metaDataColumn.displayName) {
                        var labelData = [ metaDataColumn.displayName ], translatedLabelY = this.getTranslateY(valueTextHeightInPx + categoryLabelHeightWithPadding + translateY), labelElement = this.labelContext.attr("transform", visuals.SVGUtil.translate(translateX, translatedLabelY)).selectAll("text").data(labelData);
                        labelElement.enter().append("text").attr("class", Card.Label.class), labelElement.text(function(d) {
                            return d;
                        }).style(visuals.FontProperties.toSVGStyle(categoryLabelSetting.fontProperties)).style({
                            "text-anchor": this.getTextAnchor()
                        });
                        var labelElementNode = labelElement.node();
                        labelElementNode && (formatSettings.wordWrap ? TextUtil.wordBreak(labelElementNode, width / 2, height - translatedLabelY, void 0, !0) : labelElement.call(visuals.AxisHelper.LabelLayoutStrategy.clip, width, powerbi.TextMeasurementService.svgEllipsis)), 
                        labelElement.append("title").text(function(d) {
                            return d;
                        }), labelElement.exit().remove();
                    } else this.labelContext.selectAll("text").remove();
                } else statusGraphicInfo ? (this.graphicsContext.selectAll("text").remove(), this.displayStatusGraphic(statusGraphicInfo, translateX, translateY, valueTextHeightInPx)) : (this.kpiImage.selectAll("div").remove(), 
                this.doValueTransition(start, target, this.displayUnitSystemType, this.animationOptions, duration, forceUpdate, formatter), 
                this.graphicsContext.call(visuals.tooltipUtils.tooltipUpdate, [ target ]));
                this.value = target, this.dataPointObjects = dataPointObjects;
            }, Card.prototype.displayStatusGraphic = function(statusGraphicInfo, translateX, translateY, labelTextSizeInPx) {
                this.graphicsContext.selectAll("text").remove();
                var kpiImageDiv = this.kpiImage.select("div");
                kpiImageDiv && !kpiImageDiv.empty() || (kpiImageDiv = this.kpiImage.append("div")), 
                kpiImageDiv.attr("class", statusGraphicInfo.class).style("position", "absolute").style("font-size", labelTextSizeInPx + "px");
                var imageWidth = kpiImageDiv.node().offsetWidth, imageHeight = kpiImageDiv.node().offsetHeight;
                kpiImageDiv.style("transform", visuals.SVGUtil.translateWithPixels(translateX - imageWidth / 2, this.getTranslateY(labelTextSizeInPx + translateY) - imageHeight));
            }, Card.prototype.getDefaultFormatSettings = function() {
                return {
                    labelSettings: visuals.LabelUtils.getDefaultLabelSettings(!0, CardDefaultStyle.value.color, CardDefaultStyle.value.textSize, CardDefaultStyle.value.fontFamily),
                    categoryLabelSetting: visuals.LabelUtils.getDefaultLabelSettings(!0, CardDefaultStyle.label.color, CardDefaultStyle.label.textSize, CardDefaultStyle.label.fontFamily),
                    wordWrap: !1
                };
            }, Card.prototype.getDataLabelSettingsOptions = function(enumeration, labelSettings, isNum) {
                return {
                    enumeration: enumeration,
                    dataLabelsSettings: labelSettings,
                    show: !0,
                    displayUnits: isNum,
                    precision: isNum,
                    fontSize: !0,
                    fontFamily: this.customFontFamilyForDataLabel
                };
            }, Card.prototype.enumerateObjectInstances = function(options) {
                this.cardFormatSetting || (this.cardFormatSetting = this.getDefaultFormatSettings());
                var formatSettings = this.cardFormatSetting, labelSettings = formatSettings.labelSettings, categoryLabelSetting = formatSettings.categoryLabelSetting, enumeration = new visuals.ObjectEnumerationBuilder();
                switch (options.objectName) {
                  case "categoryLabels":
                    visuals.LabelUtils.enumerateDataLabels(this.getDataLabelSettingsOptions(enumeration, categoryLabelSetting, !1));
                    break;

                  case "labels":
                    visuals.LabelUtils.enumerateDataLabels(this.getDataLabelSettingsOptions(enumeration, labelSettings, !0));
                    break;

                  case "wordWrap":
                    enumeration.pushInstance({
                        objectName: "wordWrap",
                        selector: null,
                        properties: {
                            show: formatSettings.wordWrap
                        }
                    });
                }
                return enumeration.complete();
            }, Card.cardClassName = "card", Card.Label = createClassAndSelector("label"), Card.Value = createClassAndSelector("value"), 
            Card.KPIImage = createClassAndSelector("caption"), Card.cardTextProperties = {
                fontSize: null,
                text: null,
                fontFamily: visuals.LabelUtils.defaultFontProperties.family
            }, Card;
        }(visuals.AnimatedText);
        visuals.Card = Card;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {})), define("SingleValueVisuals/cardModule", [ "require", "exports" ], function(require, exports) {
    function createCard(options) {
        return new powerbi.visuals.Card(options);
    }
    Object.defineProperty(exports, "__esModule", {
        value: !0
    }), exports.createCard = createCard;
});

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var createClassAndSelector = jsCommon.CssConstants.createClassAndSelector, DataRoleHelper = powerbi.data.DataRoleHelper, Gauge = function() {
            function Gauge(options) {
                this.lastAngle = -Math.PI / 2, options && (options.gaugeSmallViewPortProperties && (this.gaugeSmallViewPortProperties = options.gaugeSmallViewPortProperties), 
                this.animator = options.animator, this.tooltipsEnabled = options.tooltipsEnabled, 
                this.touchScreenOptimizedTooltipsEnabled = options.touchScreenOptimizedTooltipsEnabled, 
                this.customFontFamilyForDataLabel = options.customFontFamilyForDataLabel);
            }
            return Gauge.prototype.enumerateObjectInstances = function(options) {
                var enumeration = new visuals.ObjectEnumerationBuilder();
                switch (options.objectName) {
                  case "axis":
                    this.enumerateAxis(enumeration);
                    break;

                  case "labels":
                    var labelSettings = this.data ? this.data.minLabel.settings : visuals.GaugeConverter.getDefaultGaugeLabelSettings();
                    visuals.LabelUtils.enumerateDataLabels(this.getDataLabelSettingsOptions(enumeration, labelSettings));
                    break;

                  case "target":
                    var targetLabelSettings = this.data && this.data.target ? this.data.target.label.settings : visuals.GaugeConverter.getDefaultGaugeLabelSettings();
                    visuals.LabelUtils.enumerateDataLabels(this.getDataLabelSettingsOptions(enumeration, targetLabelSettings));
                    break;

                  case "calloutValue":
                    var labelSettings = this.data ? this.data.calloutLabel.settings : visuals.GaugeConverter.getDefaultGaugeLabelSettings();
                    visuals.LabelUtils.enumerateDataLabels(this.getDataLabelSettingsOptions(enumeration, labelSettings));
                    break;

                  case "dataPoint":
                    this.enumerateDataPoint(enumeration);
                }
                return enumeration.complete();
            }, Gauge.prototype.getDataLabelSettingsOptions = function(enumeration, labelSettings) {
                return {
                    dataLabelsSettings: labelSettings,
                    show: !0,
                    precision: !0,
                    displayUnits: !0,
                    fontSize: !0,
                    fontFamily: this.customFontFamilyForDataLabel,
                    enumeration: enumeration
                };
            }, Gauge.prototype.enumerateAxis = function(enumeration) {
                var dataView = this.dataView;
                if (dataView && dataView.metadata) {
                    var properties = Gauge.getGaugeObjectsProperties(dataView);
                    enumeration.pushInstance({
                        selector: null,
                        objectName: "axis",
                        properties: properties
                    });
                }
            }, Gauge.prototype.enumerateDataPoint = function(enumeration) {
                var dataPointSettings = this.data ? this.data.dataPointSettings : Gauge.DefaultDataPointSettings, properties = {};
                properties.fill = {
                    solid: {
                        color: dataPointSettings.fillColor
                    }
                }, null != dataPointSettings.targetColor && (properties.target = {
                    solid: {
                        color: dataPointSettings.targetColor
                    }
                }), enumeration.pushInstance({
                    selector: null,
                    objectName: visuals.gaugeProps.dataPoint.target.objectName,
                    properties: properties
                });
            }, Gauge.getGaugeObjectsProperties = function(dataView) {
                var properties = {}, objects = dataView.metadata.objects, hasAxisObject = !!objects && !!objects.axis;
                return DataRoleHelper.hasRoleInDataView(dataView, visuals.gaugeRoleNames.minValue) || (properties.min = hasAxisObject ? objects.axis.min : void 0), 
                DataRoleHelper.hasRoleInDataView(dataView, visuals.gaugeRoleNames.maxValue) || (properties.max = hasAxisObject ? objects.axis.max : void 0), 
                DataRoleHelper.hasRoleInDataView(dataView, visuals.gaugeRoleNames.targetValue) || (properties.target = hasAxisObject ? objects.axis.target : void 0), 
                properties;
            }, Gauge.prototype.init = function(options) {
                this.element = options.element, this.currentViewport = options.viewport, this.style = options.style, 
                this.options = options, this.settings = Gauge.DefaultStyleProperties, this.tooltipService = visuals.createTooltipService(options.host, this.touchScreenOptimizedTooltipsEnabled), 
                this.labelPosition = 0, this.margin = {
                    top: 0,
                    left: 0,
                    right: 0,
                    bottom: 0
                }, this.color = d3.scale.ordinal().range(this.style.colorPalette.dataColors.getSentimentColors().map(function(color) {
                    return color.value;
                })), this.hostService = options.host;
                var svg = this.svg = d3.select(this.element.get(0)).append("svg");
                svg.classed(Gauge.VisualClassName, !0);
                var mainGraphicsContext = this.mainGraphicsContext = svg.append("g");
                mainGraphicsContext.attr("class", Gauge.MainGaugeGroupClassName), this.initKpiBands();
                var backgroundArc = this.backgroundArc = d3.svg.arc().innerRadius(0).outerRadius(0).startAngle(-Math.PI / 2).endAngle(Math.PI / 2), foregroundArc = this.foregroundArc = d3.svg.arc().innerRadius(0).outerRadius(0).startAngle(-Math.PI / 2);
                this.backgroundArcPath = mainGraphicsContext.append("path").classed("backgroundArc", !0).attr("d", backgroundArc), 
                this.foregroundArcPath = mainGraphicsContext.append("path").datum({
                    endAngle: -Math.PI / 2
                }).classed("foregroundArc", !0).attr("d", foregroundArc);
                var g = this.animatedNumberGrapicsContext = svg.append("g");
                this.animatedNumber = new visuals.AnimatedNumber(g), this.animatedNumber.init(options);
                var gaugeDrawingOptions = this.gaugeVisualProperties = this.getGaugeVisualProperties(), animatedNumberProperties = this.getAnimatedNumberProperties(gaugeDrawingOptions.radius, gaugeDrawingOptions.innerRadiusFactor, gaugeDrawingOptions.top, gaugeDrawingOptions.left);
                this.animatedNumberGrapicsContext.attr("transform", animatedNumberProperties.transformString), 
                this.animatedNumber.onResizing(animatedNumberProperties.viewport);
            }, Gauge.prototype.update = function(options) {
                if (this.currentViewport = options.viewport, options.dataViews && options.dataViews[0]) {
                    var dataView = this.dataView = options.dataViews[0], reader = powerbi.data.createDataViewCategoricalReaderAdvanced(dataView);
                    if (options.type & powerbi.VisualUpdateType.Data || !this.data) {
                        this.data = visuals.GaugeConverter.convert(reader, this.style);
                        var warnings = visuals.getInvalidValueWarnings([ dataView ], !1, !1, !1, [ "Tooltips" ]);
                        this.hostService.setWarnings(warnings);
                    }
                    (options.type & powerbi.VisualUpdateType.Resize || options.type & powerbi.VisualUpdateType.ResizeEnd) && (options.suppressAnimations = !0), 
                    this.dataView.single = {
                        value: this.data.calloutLabel.value,
                        column: void 0
                    }, this.labels = [ this.data.minLabel, this.data.maxLabel ], this.showTargetLabel = this.data.target.ratio >= 0 && this.data.target.ratio <= 1 && this.currentViewport.width > Gauge.MinWidthForTargetLabel && this.showSideNumbersLabelText() && this.data.target.label.settings.show;
                    var position = Gauge.calculatePosition(this.data, this.showTargetLabel, this.currentViewport, this.gaugeSmallViewPortProperties);
                    this.labelPosition = position.labelPosition, this.margin = position.margin, this.gaugeVisualProperties = this.getGaugeVisualProperties(), 
                    this.drawViewPort(this.gaugeVisualProperties), this.updateInternal(options.suppressAnimations), 
                    this.updateCalloutValue(options.suppressAnimations);
                }
            }, Gauge.prototype.updateCalloutValue = function(suppressAnimations) {
                var calloutValueLabelsSettings = this.data.calloutLabel.settings;
                if (this.data.calloutLabel.settings.show) {
                    var animatedNumberProperties = this.getAnimatedNumberProperties(this.gaugeVisualProperties.radius, this.gaugeVisualProperties.innerRadiusFactor, this.gaugeVisualProperties.top, this.gaugeVisualProperties.left);
                    this.animatedNumberGrapicsContext.attr("transform", animatedNumberProperties.transformString), 
                    this.animatedNumber.setTextColor(calloutValueLabelsSettings.fontProperties.color);
                    var calloutValue = this.data.calloutLabel.value, formatter = this.data.calloutLabel.formatter;
                    this.animatedNumber.setFormatter(formatter), this.animatedNumber.update({
                        viewport: animatedNumberProperties.viewport,
                        dataViews: [ this.dataView ],
                        suppressAnimations: suppressAnimations
                    }), this.animatedNumberGrapicsContext.selectAll("title").remove(), this.animatedNumberGrapicsContext.append("title").text([ formatter.format(calloutValue) ]);
                } else this.animatedNumber.clear(), this.animatedNumberGrapicsContext.selectAll("title").remove();
            }, Gauge.prototype.initKpiBands = function() {
                if (this.settings.kpiBands.show) for (var kpiArcs = this.kpiArcs = [], kpiArcPaths = this.kpiArcPaths = [], mainGraphicsContext = this.mainGraphicsContext, i = 0; i < 3; i++) {
                    var arc = d3.svg.arc().innerRadius(0).outerRadius(0).startAngle(0).endAngle(0);
                    kpiArcs.push(arc);
                    var arcPath = mainGraphicsContext.append("path").attr("d", arc);
                    kpiArcPaths.push(arcPath);
                }
            }, Gauge.prototype.updateKpiBands = function(radius, innerRadiusFactor, tString, kpiAngleAttr) {
                if (this.settings.kpiBands.show) for (var i = 0; i < kpiAngleAttr.length; i++) this.kpiArcs[i].innerRadius(radius * innerRadiusFactor - (Gauge.KpiBandDistanceFromMainArc + this.settings.kpiBands.thickness)).outerRadius(radius * innerRadiusFactor - Gauge.KpiBandDistanceFromMainArc).startAngle(kpiAngleAttr[i].start).endAngle(kpiAngleAttr[i].end), 
                this.kpiArcPaths[i].attr("fill", kpiAngleAttr[i].fill).attr("d", this.kpiArcs[i]).attr("transform", tString);
            }, Gauge.prototype.removeTargetElements = function() {
                this.targetLine && (this.targetLine.remove(), this.targetText.remove(), this.targetConnector.remove(), 
                this.targetLine = this.targetConnector = this.targetText = null);
            }, Gauge.prototype.updateTargetLine = function(radius, innerRadius, left, top) {
                this.targetLine || (this.targetLine = this.mainGraphicsContext.append("line"));
                var angle = this.data.target.ratio * Math.PI, outY = top - radius * Math.sin(angle), outX = left - radius * Math.cos(angle), inY = top - innerRadius * Math.sin(angle), inX = left - innerRadius * Math.cos(angle);
                this.targetLine.attr({
                    x1: inX,
                    y1: inY,
                    x2: outX,
                    y2: outY
                });
            }, Gauge.prototype.getAnimatedNumberProperties = function(radius, innerRadiusFactor, top, left) {
                var boxAngle = Math.PI / 4, scale = 1, innerRadiusOfArc = radius * innerRadiusFactor, innerRadiusForTextBoundingBox = innerRadiusOfArc - (this.settings.kpiBands.show ? Gauge.KpiBandDistanceFromMainArc + this.settings.kpiBands.thickness : 0), innerRCos = innerRadiusForTextBoundingBox * Math.cos(boxAngle), innerRSin = innerRadiusForTextBoundingBox * Math.sin(boxAngle), innerY = top - innerRSin, innerX = left - innerRCos;
                innerY *= scale, innerX *= scale;
                var animatedNumberWidth = 2 * innerRCos, properties = {
                    transformString: visuals.SVGUtil.translate(innerX, innerY),
                    viewport: {
                        height: innerRSin,
                        width: animatedNumberWidth
                    }
                };
                return properties;
            }, Gauge.prototype.getGaugeVisualProperties = function() {
                var viewport = this.currentViewport, margin = this.margin, width = viewport.width - margin.right - margin.left, halfWidth = width / 2, height = viewport.height - margin.top - margin.bottom, radius = Math.min(halfWidth, height), innerRadiusFactor = Gauge.InnerRadiusFactor, left = margin.left + halfWidth, top = radius + (height - radius) / 2 + margin.top, tString = visuals.SVGUtil.translate(left, top), innerRadiusOfArc = radius * innerRadiusFactor, gaugeData = {
                    radius: radius,
                    innerRadiusOfArc: innerRadiusOfArc,
                    left: left,
                    top: top,
                    height: height,
                    width: width,
                    margin: margin,
                    transformString: tString,
                    innerRadiusFactor: innerRadiusFactor
                };
                return gaugeData;
            }, Gauge.prototype.drawViewPort = function(drawOptions) {
                var separation = this.settings.kpiBands.separationRadians, innerRadiusFactor = Gauge.InnerRadiusFactor, backgroudArc = this.backgroundArc, color = this.color, attrs = [ {
                    fill: color(0),
                    start: -Math.PI / 2,
                    end: -Math.PI / 2 + Math.PI / 4 - separation
                }, {
                    fill: color(1),
                    start: -Math.PI / 2 + 1 * Math.PI / 4 + separation,
                    end: -Math.PI / 2 + 3 * Math.PI / 4 - separation
                }, {
                    fill: color(2),
                    start: -Math.PI / 2 + 3 * Math.PI / 4 + separation,
                    end: Math.PI / 2
                } ], radius = drawOptions.radius, transformString = drawOptions.transformString;
                this.updateKpiBands(radius, innerRadiusFactor, transformString, attrs), backgroudArc.innerRadius(radius * innerRadiusFactor).outerRadius(radius).startAngle(-Math.PI / 2).endAngle(Math.PI / 2), 
                this.backgroundArcPath.attr("d", backgroudArc).attr("transform", transformString);
                var foregroundArc = this.foregroundArc;
                foregroundArc.innerRadius(radius * innerRadiusFactor).outerRadius(radius).startAngle(-Math.PI / 2), 
                this.foregroundArcPath.datum({
                    endAngle: this.lastAngle
                }).attr("transform", transformString).attr("d", foregroundArc);
                var innerRadiusOfArc = drawOptions.innerRadiusOfArc, left = drawOptions.left, top = drawOptions.top, margin = drawOptions.margin, height = drawOptions.height;
                this.settings.targetLine.show && $.isNumeric(this.data.target.label.value) ? this.data.target.ratio < 0 || this.data.target.ratio > 1 ? this.removeTargetElements() : (this.updateTargetLine(radius, innerRadiusOfArc, left, top), 
                this.renderTarget(radius, height, drawOptions.width, margin)) : this.removeTargetElements(), 
                this.svg.attr("height", this.currentViewport.height).attr("width", this.currentViewport.width);
            }, Gauge.prototype.updateInternal = function(suppressAnimations) {
                var height = this.gaugeVisualProperties.height, width = this.gaugeVisualProperties.width, radius = this.gaugeVisualProperties.radius, margin = this.margin, duration = visuals.AnimatorCommon.GetAnimationDuration(this.animator, suppressAnimations), data = this.data, lastAngle = this.lastAngle = -Math.PI / 2 + Math.PI * this.data.ratio;
                this.foregroundArcPath.transition().ease(this.settings.transition.ease).duration(duration).call(this.arcTween, [ lastAngle, this.foregroundArc ]), 
                this.renderMinMaxLabels(this.labels, radius, height, width, margin), this.updateVisualConfigurations(), 
                this.tooltipsEnabled && (this.tooltipService.addTooltip(this.foregroundArcPath, function(args) {
                    return data.tooltipInfo;
                }, function(args) {}), this.tooltipService.addTooltip(this.backgroundArcPath, function(args) {
                    return data.tooltipInfo;
                }, function(args) {}));
            }, Gauge.prototype.updateVisualConfigurations = function() {
                var configOptions = this.settings, dataPointSettings = this.data.dataPointSettings;
                this.mainGraphicsContext.select("line").attr({
                    stroke: dataPointSettings.targetColor,
                    "stroke-width": configOptions.targetLine.thickness
                }), this.backgroundArcPath.style("fill", configOptions.arcColors.background), this.foregroundArcPath.style("fill", dataPointSettings.fillColor);
            }, Gauge.prototype.renderMinMaxLabels = function(ticks, radius, height, width, margin) {
                this.svg.selectAll(Gauge.LabelText.selector).remove();
                var fillColor = this.data.minLabel.settings.fontProperties.color;
                if (this.data.minLabel.settings.show) for (var dataLabelsSettings = this.data.minLabel.settings, total = ticks.length, divisor = total - 1, position = this.labelPosition, fontProperties = visuals.FontProperties.inherit(dataLabelsSettings.fontProperties, {
                    color: fillColor
                }), fontSize = fontProperties.size.px, padding = this.settings.labels.padding, index = 0; index < total; index++) {
                    var y = this.gaugeVisualProperties.top, textProperties = visuals.FontProperties.toTextProperties(fontProperties, ticks[index].text);
                    if (this.showSideNumbersLabelText()) {
                        var x = margin.left + width / 2 - radius * Math.cos(Math.PI * index / divisor), anchor = void 0, onRight = 1 === index, onBottom = !1;
                        2 === position ? (onBottom = !0, y += padding, anchor = onRight ? "end" : "start", 
                        textProperties.text = powerbi.TextMeasurementService.getTailoredTextOrDefault(textProperties, radius)) : (anchor = onRight ? "start" : "end", 
                        x += padding * (onRight ? 1 : -1));
                        var text = this.mainGraphicsContext.append("text").attr({
                            x: x,
                            y: y,
                            dy: onBottom ? fontSize : 0,
                            class: Gauge.LabelText.class
                        }).style({
                            "text-anchor": anchor
                        }).style(visuals.FontProperties.toSVGStyle(fontProperties)).text(textProperties.text).append("title").text(textProperties.text);
                        onBottom || this.truncateTextIfNeeded(text, x, onRight);
                    }
                }
            }, Gauge.prototype.truncateTextIfNeeded = function(text, positionX, onRight) {
                var availableSpace = onRight ? this.currentViewport.width - positionX : positionX;
                text.call(visuals.AxisHelper.LabelLayoutStrategy.clip, availableSpace, powerbi.TextMeasurementService.svgEllipsis);
            }, Gauge.prototype.renderTarget = function(radius, height, width, margin) {
                var targetLabel = this.data.target, settings = this.data.target.label.settings, target = targetLabel.label.value, tRatio = targetLabel.ratio, top = radius + (height - radius) / 2 + margin.top, flag = tRatio > .5, padding = this.settings.labels.padding, anchor = flag ? "start" : "end", formatter = this.data.target.label.formatter, maxRatio = Math.asin(Gauge.MinDistanceFromBottom / radius) / Math.PI, finalRatio = tRatio < maxRatio || tRatio > 1 - maxRatio ? flag ? 1 - maxRatio : maxRatio : tRatio, targetX = margin.left + width / 2 - (radius + padding) * Math.cos(Math.PI * finalRatio), targetY = top - (radius + padding) * Math.sin(Math.PI * finalRatio);
                this.targetText || (this.targetText = this.mainGraphicsContext.append("text").classed(Gauge.TargetText.class, !0)), 
                this.targetText.attr({
                    x: targetX,
                    y: targetY
                }).style({
                    display: this.showTargetLabel ? "" : "none",
                    "text-anchor": anchor
                }).style(visuals.FontProperties.toSVGStyle(settings.fontProperties)).text(formatter.format(target)), 
                this.truncateTextIfNeeded(this.targetText, targetX, flag), this.targetText.call(visuals.tooltipUtils.tooltipUpdate, [ formatter.format(target) ]), 
                this.targetConnector || (this.targetConnector = this.mainGraphicsContext.append("line").classed(Gauge.TargetConnector.class, !0)), 
                tRatio === finalRatio ? this.targetConnector.style("display", "none") : this.targetConnector.attr({
                    x1: margin.left + width / 2 - radius * Math.cos(Math.PI * tRatio),
                    y1: top - radius * Math.sin(Math.PI * tRatio),
                    x2: targetX,
                    y2: targetY
                }).style({
                    "stroke-width": this.settings.targetLine.thickness,
                    stroke: this.settings.targetLine.color,
                    display: ""
                });
            }, Gauge.prototype.arcTween = function(transition, arr) {
                transition.attrTween("d", function(d) {
                    var interpolate = d3.interpolate(d.endAngle, arr[0]);
                    return function(t) {
                        return d.endAngle = interpolate(t), arr[1](d);
                    };
                });
            }, Gauge.calculatePosition = function(viewModel, showTargetLabel, viewport, gaugeSmallViewPortProperties) {
                var settings = Gauge.DefaultStyleProperties, result = {
                    margin: {
                        top: 0,
                        left: 0,
                        bottom: 0,
                        right: 0
                    },
                    labelPosition: 0
                };
                if (gaugeSmallViewPortProperties && gaugeSmallViewPortProperties.smallGaugeMarginsOnSmallViewPort && viewport.height < gaugeSmallViewPortProperties.MinHeightGaugeSideNumbersVisible) {
                    var margins = gaugeSmallViewPortProperties.GaugeMarginsOnSmallViewPort;
                    return result.margin = {
                        top: margins,
                        bottom: margins,
                        left: margins,
                        right: margins
                    }, result;
                }
                if (!viewModel) return result;
                var padding = 2 * settings.labels.padding, showLabels = viewModel && viewModel.minLabel.settings.show;
                if (showTargetLabel) {
                    var tRatio = viewModel.target.ratio <= .5 ? viewModel.target.ratio : 1 - viewModel.target.ratio, angle = tRatio * Math.PI, requiredWidth = viewModel.target.label.requiredSpace.width + padding, maxWidthRadius = (viewport.width - requiredWidth) / (Math.cos(angle) + 1), delta = viewport.width - 2 * maxWidthRadius;
                    delta > 0 && (viewModel.target.ratio < .5 ? result.margin.left = delta : result.margin.right = delta);
                    var maxHeightRadius = (viewport.height - viewModel.target.label.requiredSpace.height - padding) / Math.sin(angle);
                    delta = viewport.height - maxHeightRadius, delta > 0 && (result.margin.top = delta);
                }
                if (showLabels) {
                    var leftMargin = Math.max(result.margin.left, viewModel.minLabel.requiredSpace.width + padding), rightMargin = Math.max(result.margin.right, viewModel.maxLabel.requiredSpace.width + padding), bottomMargin = viewModel.minLabel.requiredSpace.height + padding, sidePositionRadius = (viewport.width - leftMargin - rightMargin) / 2, bottomPositionRadius = viewport.height - result.margin.top - bottomMargin;
                    bottomPositionRadius > sidePositionRadius ? (result.labelPosition = 2, result.margin.bottom = bottomMargin) : (result.labelPosition = 1, 
                    result.margin = {
                        left: leftMargin,
                        right: rightMargin,
                        top: result.margin.top,
                        bottom: settings.labels.padding
                    });
                }
                return result;
            }, Gauge.prototype.showSideNumbersLabelText = function() {
                return !(this.gaugeSmallViewPortProperties && this.gaugeSmallViewPortProperties.hideGaugeSideNumbersOnSmallViewPort && this.currentViewport.height < this.gaugeSmallViewPortProperties.MinHeightGaugeSideNumbersVisible);
            }, Gauge.MinDistanceFromBottom = 10, Gauge.MinWidthForTargetLabel = 150, Gauge.VisualClassName = "gauge", 
            Gauge.DefaultStyleProperties = {
                transition: {
                    ease: "cubic-in-out"
                },
                arcColors: {
                    background: "#e9e9e9",
                    foreground: "#00B8AA"
                },
                targetLine: {
                    show: !0,
                    color: "#666666",
                    thickness: 2
                },
                labels: {
                    count: 2,
                    padding: 5,
                    fontSize: visuals.LabelUtils.DefaultLabelFontSizeInPt
                },
                kpiBands: {
                    show: !1,
                    separationRadians: Math.PI / 128,
                    thickness: 5
                }
            }, Gauge.DefaultDataPointSettings = {
                fillColor: Gauge.DefaultStyleProperties.arcColors.foreground,
                targetColor: Gauge.DefaultStyleProperties.targetLine.color
            }, Gauge.InnerRadiusFactor = .7, Gauge.KpiBandDistanceFromMainArc = 2, Gauge.MainGaugeGroupClassName = "mainGroup", 
            Gauge.LabelText = createClassAndSelector("labelText"), Gauge.TargetConnector = createClassAndSelector("targetConnector"), 
            Gauge.TargetText = createClassAndSelector("targetText"), Gauge;
        }();
        visuals.Gauge = Gauge;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {}));

var powerbi;

!function(powerbi) {
    var visuals;
    !function(visuals) {
        var DEFAULT_MAX = 1, DEFAULT_MIN = 0, DEFAULT_FILL_COLOR = "#00B8AA", DEFAULT_TARGET_COLOR = "#666666", GaugeConverter = function() {
            function GaugeConverter() {}
            return GaugeConverter.getDefaultGaugeLabelSettings = function() {
                return {
                    show: !0,
                    displayUnits: 0,
                    precision: visuals.dataLabelUtils.defaultLabelPrecision,
                    position: null,
                    fontProperties: visuals.FontProperties.inherit(visuals.LabelUtils.defaultFontProperties, {
                        size: visuals.Units.FontSize.createFromPt(visuals.LabelUtils.minLabelFontSize)
                    })
                };
            }, GaugeConverter.convert = function(reader, style) {
                var columnReader = reader.columns, staticObjects = reader.objects.getStaticObjects(), valueColumnMetadata = columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.y), data = this.parseGaugeData(reader), labelsSettings = this.convertDataLabelSettings(staticObjects, "labels"), targetSettings = this.convertDataLabelSettings(staticObjects, "target"), dataColors = style && style.colorPalette.dataColors.getAllColors(), defaultFillColor = dataColors && dataColors.length >= 1 && dataColors[0].value || DEFAULT_FILL_COLOR, defaultTargetColor = dataColors && dataColors.length >= 2 && dataColors[1].value || DEFAULT_TARGET_COLOR;
                return {
                    maxLabel: this.createLabel(data.max, columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.maxValue), labelsSettings, valueColumnMetadata),
                    minLabel: this.createLabel(data.min, columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.minValue), labelsSettings, valueColumnMetadata, data.max),
                    target: {
                        label: this.createLabel(data.target, columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.targetValue), targetSettings, valueColumnMetadata),
                        ratio: this.getTargetRatio(data)
                    },
                    calloutLabel: this.createLabel(data.value, valueColumnMetadata, this.convertDataLabelSettings(staticObjects, "calloutValue"), valueColumnMetadata),
                    tooltipInfo: data.tooltipItems,
                    ratio: this.getValueRatio(data),
                    dataPointSettings: this.convertDataPointSettings(staticObjects, data, defaultFillColor, defaultTargetColor)
                };
            }, GaugeConverter.parseGaugeData = function(reader) {
                var columnReader = reader.columns, dataViewObjects = reader.objects.getStaticObjects(), valueColumnMetadata = columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.y), axisObject = dataViewObjects ? dataViewObjects.axis : null, isValueDefined = reader.data.hasValues(visuals.gaugeRoleNames.y), isMaxDefined = reader.data.hasValues(visuals.gaugeRoleNames.maxValue), isMinDefined = reader.data.hasValues(visuals.gaugeRoleNames.minValue), valueIndex = 0, data = {
                    max: null,
                    min: null,
                    target: null,
                    value: null,
                    tooltipItems: []
                };
                if (isValueDefined) {
                    data.value = reader.data.getValue(visuals.gaugeRoleNames.y, valueIndex);
                    var value = visuals.converterHelper.formatFromMetadataColumn(data.value, valueColumnMetadata, this.formatStringProp, !1);
                    data.tooltipItems.push({
                        displayName: reader.data.getValueDisplayName(visuals.gaugeRoleNames.y),
                        value: value
                    });
                }
                if (reader.data.hasValues(visuals.gaugeRoleNames.targetValue)) {
                    var targetMetadata = columnReader.getValueMetadataColumn(visuals.gaugeRoleNames.targetValue);
                    data.target = reader.data.getValue(visuals.gaugeRoleNames.targetValue, valueIndex);
                    var value = visuals.converterHelper.formatFromMetadataColumn(data.target, targetMetadata, this.formatStringProp, !1);
                    data.tooltipItems.push({
                        displayName: reader.data.getValueDisplayName(visuals.gaugeRoleNames.targetValue),
                        value: value
                    });
                } else axisObject && (data.target = axisObject.target);
                if (isMaxDefined) data.max = reader.data.getValue(visuals.gaugeRoleNames.maxValue, valueIndex); else if (axisObject && null != axisObject.max) data.max = axisObject.max; else if (data.max = DEFAULT_MAX, 
                isValueDefined && data.value && 0 !== data.value) {
                    var hasPercent = !1;
                    if (valueColumnMetadata) {
                        var formatString = visuals.valueFormatter.getFormatString(valueColumnMetadata, this.formatStringProp, !0);
                        null != formatString && (hasPercent = visuals.valueFormatter.getFormatMetadata(formatString).hasPercent);
                    }
                    hasPercent || (data.max = data.value < 0 ? DEFAULT_MIN : 2 * data.value);
                }
                return isMinDefined ? data.min = reader.data.getValue(visuals.gaugeRoleNames.minValue, valueIndex) : axisObject && null != axisObject.min ? data.min = axisObject.min : (data.min = DEFAULT_MIN, 
                isValueDefined && null != data.value && data.value < 0 && (data.min = 2 * data.value)), 
                visuals.TooltipBuilder.addTooltipMeasures(reader, data.tooltipItems, valueIndex, void 0, this.formatStringProp), 
                data;
            }, GaugeConverter.createLabel = function(value, metadata, settings, fallbackMetadata, max) {
                var fontProperties = settings ? settings.fontProperties : visuals.LabelUtils.defaultFontProperties, textProperties = visuals.FontProperties.toTextProperties(fontProperties), formatter = this.getFormatter(settings, metadata, fallbackMetadata, max || value);
                return textProperties.text = formatter.format(value), {
                    value: value,
                    requiredSpace: {
                        width: powerbi.TextMeasurementService.measureSvgTextWidth(textProperties),
                        height: powerbi.TextMeasurementService.estimateSvgTextHeight(textProperties)
                    },
                    text: textProperties.text,
                    formatter: formatter,
                    settings: settings
                };
            }, GaugeConverter.getFormatter = function(dataLabelSettings, metadataColumn, fallbackMetadata, maxValue) {
                var max = 0 === dataLabelSettings.displayUnits ? maxValue : null;
                metadataColumn && metadataColumn.objects && !_.isEmpty(powerbi.DataViewObjects.getValue(metadataColumn.objects, this.formatStringProp)) || (metadataColumn = fallbackMetadata);
                var formatString = visuals.valueFormatter.getFormatString(metadataColumn, this.formatStringProp), precision = visuals.dataLabelUtils.getLabelPrecision(dataLabelSettings.precision, formatString), valueFormatterOptions = visuals.LabelUtils.getOptionsForLabelFormatter(dataLabelSettings, formatString, max, precision);
                return valueFormatterOptions.formatSingleValues = !(dataLabelSettings.displayUnits > 0), 
                0 === dataLabelSettings.displayUnits && (valueFormatterOptions.value = max), visuals.valueFormatter.create(valueFormatterOptions);
            }, GaugeConverter.getValueRatio = function(data) {
                if (!_.isNumber(data.value) || !this.isValid(data) || data.value <= data.min) return 0;
                if (data.value >= data.max) return 1;
                var diff = data.max - data.min, angle = (data.value - data.min) / diff;
                return angle;
            }, GaugeConverter.isValid = function(data) {
                return _.isNumber(data.min) && _.isNumber(data.max) && data.min <= data.max;
            }, GaugeConverter.getTargetRatio = function(data) {
                if (!this.isValid(data) || !_.isNumber(data.target)) return -1;
                var range = data.max - data.min;
                return 0 !== range ? (data.target - data.min) / range : 0;
            }, GaugeConverter.convertDataLabelSettings = function(objects, objectName) {
                var dataLabelsSettings = GaugeConverter.getDefaultGaugeLabelSettings();
                if (objects) {
                    var labelsObj = objects[objectName];
                    visuals.LabelUtils.updateLabelSettingsFromLabelsObject(labelsObj, dataLabelsSettings);
                }
                return dataLabelsSettings;
            }, GaugeConverter.convertDataPointSettings = function(objects, targetSettings, defaultFillColor, defaultTargetColor) {
                return {
                    fillColor: powerbi.DataViewObjects.getFillColor(objects, visuals.gaugeProps.dataPoint.fill, defaultFillColor),
                    targetColor: powerbi.DataViewObjects.getFillColor(objects, visuals.gaugeProps.dataPoint.target, defaultTargetColor)
                };
            }, GaugeConverter.formatStringProp = {
                objectName: "general",
                propertyName: "formatString"
            }, GaugeConverter;
        }();
        visuals.GaugeConverter = GaugeConverter;
    }(visuals = powerbi.visuals || (powerbi.visuals = {}));
}(powerbi || (powerbi = {})), define("SingleValueVisuals/gaugeModule", [ "require", "exports" ], function(require, exports) {
    function createGauge(options) {
        return new powerbi.visuals.Gauge(options);
    }
    Object.defineProperty(exports, "__esModule", {
        value: !0
    }), exports.createGauge = createGauge;
});